home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STSPCTRT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.3 KB  |  43 lines

  1. #include <stdio.h>
  2. #include <graphics.h>
  3.  
  4. main()
  5. {
  6.   int graphdriver = DETECT, graphmode;
  7.   char    buffer[80];
  8.   int     xasp, yasp, bcolor, width;
  9.  
  10.   initgraph(&graphdriver, &graphmode, "c:\\turboc");
  11.   bcolor = getbkcolor();
  12.   setfillstyle(EMPTY_FILL, 0);
  13.   settextjustify(LEFT_TEXT,BOTTOM_TEXT);
  14. /* Get the current "aspect ratio" and display it */
  15.   getaspectratio( &xasp, &yasp );
  16.   sprintf(buffer,"Aspect ratio: xasp = %d, yasp = %d", xasp, yasp);
  17.   outtextxy(100,30, buffer);
  18.   width = textwidth(buffer);
  19.   outtextxy(100,10,"Enter xasp, yasp (0,0 to exit): ");
  20. /* Draw a circle */
  21.   setcolor(RED);
  22.   circle(120,120, 80);
  23. /* Now let user alter the aspect ratio */
  24.   while(1)
  25.   {
  26. /* Read new aspect ratio parameters */
  27.     scanf(" %d , %d", &xasp, &yasp);
  28. /* Exit if either xasp or yasp is 0 */
  29.     if(xasp == 0 || yasp == 0) break;
  30. /* Erase the previous circle */
  31.     setcolor(bcolor);
  32.     circle(120,120, 80);
  33. /* Set the aspect ratio and redraw it */
  34.     setaspectratio(xasp,yasp);
  35.     setcolor(RED);
  36.     circle(120,120, 80);
  37. /* Display the new aspect ratio */
  38.     bar(100, 30-textheight("H"), 100+width, 30);
  39.     sprintf(buffer,"Aspect ratio: xasp = %d, yasp = %d", xasp, yasp);
  40.     outtextxy(100,30, buffer);
  41.   }
  42.   closegraph();      /* Exit graphics library */
  43. }